package service

import (
	"time"

	"api/db"
	"api/deamon"
	"api/loger"
)

func (m *Message) InsertActivity(title, content, picture, link string, end_time time.Time) {
	err := deamon.InsertActivity(title, content, picture, link, end_time)
	if err != nil {
		m.HaveError = true
		m.IsSuccess = false
		m.Info = err.Error()
		loger.Loger.Println("error 新增活动出现错误", err.Error())
		return
	}
	m.HaveError = false
	m.IsSuccess = true
	m.Info = "新增活动成功"
}
func (m *Message) FinishActivity(activityId int) (err error) {
	err = deamon.FinishActivity(activityId)
	if err != nil {
		m.HaveError = true
		m.IsSuccess = false
		m.Info = err.Error()
		loger.Loger.Println("error 结束活动出现错误", err.Error())
		return err
	}
	m.HaveError = false
	m.IsSuccess = true
	m.Info = "结束活动成功"
	return nil
}
func (m *Message) SelectActivitys() (activitys []db.Activity) {
	activitys = deamon.SelectActivitys()
	m.HaveError = false
	m.IsSuccess = true
	m.Result = activitys
	return activitys
}
